package com.kitty.game.fight.artifact.passive;

import com.kitty.game.fight.bean.Fight;
import com.kitty.game.fight.bean.FightObject;
import com.kitty.common.utils.SpringUtils;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
//金角剪
public class ScissorsArtifactEffect extends ArtifactEffect {

    @Override
    public short getEffectId() {
        return 8048;
    }

    @Override
    public ArtifactType getType() {
        return ArtifactType.SCISSORS;
    }

    @Override
    public Boolean trigger(Fight fight, FightObject member, Object... params) {
        if (!checkBaseCondition(fight, member)) {
            return false;
        }
        if (member.isFallDown()) {
            return false;
        }
        boolean trigger = SpringUtils.getArtifactService().getArtifactRate(getType().getName(), member.getRole());
        if (!trigger) {
            return false;
        }

        List<FightObject> targets = new ArrayList<>(fight.getTargetSide(member.getId()));
        Collections.shuffle(targets);
        // 最多三人生效
        int sum = 0;
        for (FightObject target : targets) {
            target.clearAssistBuff();
            broadCast(fight, target);
            if (++sum >= 3) {
                break;
            }
        }

        return true;
    }



}
